package com.tv.cms.utils;

import java.io.Serializable;

/**
 * TODO
 *
 * @author
 * @date
 **/
public class Result<T> implements Serializable {
    private int code;
    private String message;
    private T data;

    public Result() {}

    public Result(int code, String message) {
        this.code = code;
        this.message = message;
    }
    public static Result OK(String msg){
        return new Result(ResultCode.SUCCESS.getCode(),msg);
    }
    public static Result OK(){
        return new Result(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMsg());
    }
    public static Result FAILURE(){
        return new Result<>(ResultCode.FAILURE.getCode(),ResultCode.FAILURE.getMsg());
    }
    public static Result FAILURE(String msg){
        return new Result<>(ResultCode.FAILURE.getCode(),msg);
    }

    public static Result FAILURE(int code, String msg){
        return new Result<>(code,msg);
    }

    public Result<T> OKDATA(T data){
        return new Result<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg(), data);
    }
    public Result<T> FAILUREDATA(T data){
        return new Result<>(ResultCode.FAILURE.getCode(), ResultCode.FAILURE.getMsg(), data);
    }
    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
